<template>
	<view>
		<carHeader :title="'已完成订单'"></carHeader>
		<view class="top">
			<view class="top-top">
				<view class="top-one">
					订单信息
					<view class="success">
						已完成
					</view>
				</view>
				<view class="top-two">
					<p>订单号：{{list.orderDetailsId}}</p>
					<p>服务项目：{{list.serviceClass.serviceCategory}}</p>
					
					<p>下单时间：{{list.orderDetails.createTime}}</p>
					<p>预约时间：{{list.orderDetails.orderTime}}</p>
					<p>车辆：{{list.carBrand.cbName}}{{list.carInfo.type}}/{{list.carInfo.carNum}}</p>
					<p>备注：</p>
				</view>
			</view>
			<view class="top-center">
				<view class="center-one">
					订单详情
				</view>
				<view class="center-two" v-for="(item,index) in list2" :key="index">
					<p><span>{{item.serviceDetails.name}}</span>
						<span><span v-if="useMoney > 0">￥</span>{{item.serviceDetails.presentPrice}}</span>
					</p>
				</view>
				<view class="center-three">
					<p><span>原价</span>
						<span><span v-if="fisrtMoney > 0">￥</span>{{list.orderDetails.prePrice}}</span>
					</p>
					<p><span>店家优惠</span>
					
						<span class="money1"><span
								v-if="(fisrtMoney - reduceMoney) > 0">￥</span>{{formattedDifference}}</span>
					</p>
				</view>
				
				<view class="center-five">
					<p><span>支付金额</span>
							<span class="money2"><span v-if="reduceMoney > 0">-￥</span>{{list.orderDetails.payPrice}}</span>
					</p>
				</view>
			</view>

		</view>
		<view class="bottom">
			<view class="bottom-top">
				评价结果
			</view>
			<view class="bottom-bottom">
				<p>评价时间：{{list1.evaluationTime}}</p>
				<p>评价结果：
					<view class="star" v-for="(i,index) in 5" :key="index">
						<u-icon name="star-fill" color="#ffc100" v-if="index < list1.starRating"></u-icon>
						<u-icon name="star-fill" color="#bfbfbf" v-if="index >= list1.starRating"></u-icon>
					</view>
				</p>
				<p>评语：{{list1.evaluationContent}}</p>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				list: {
					serviceClass:'',
					orderDetails:'',
					carBrand:'',
					carInfo:'',
					serviceDetails:''
				},
				list1:{},
				list2:[{
					serviceDetails:'',
					name:'',
				}],
			}
		},
		 computed: {
		    formattedDifference() {
		      const difference = this.list.orderDetails.prePrice - this.list.orderDetails.payPrice;
		      return difference.toFixed(2);
		    }
		  },
		methods: {

		},
		onLoad(options) {
				const id = options.id; // 获取 ID
				const data = options.data ? JSON.parse(decodeURIComponent(options.data)) : {}; // 获取其他数据
				
				    console.log('ID:', id);
				    console.log('Data:', data);
		
			uni.request({
				url:`http://localhost:8080/carShop/carShop/orderEvaluation/listByOrderId?id=${encodeURIComponent(id)}`,
				success: (res) => {
					this.list=res.data
					this.list.orderDetails.prePrice
					console.log(res.data)
				}
			});
			uni.request({
				url:`http://localhost:8080/carShop/carShop/orderEvaluation/queryOrderEvaluation1?id=${encodeURIComponent(id)}`,
				success:(res) =>{
					this.list1=res.data
				}
			});
			uni.request({
				url:`http://localhost:8080/carShop/carShop/orderEvaluation/queryOrderEvaluation2?id=${encodeURIComponent(id)}`,
				success: (res) => {
					this.list2=res.data
					this.list.orderDetails.payPrice
				}
			})
		}
	}
</script>

<style lang="scss">
	.top {
		position: relative;
		top:-240rpx;
		background-color: #fff;
		border-radius: 50rpx;
		margin: 0 20rpx 20rpx;
		padding: 30rpx;

		.top-top {
			padding: 10rpx;

			.top-one {
				padding-bottom: 20rpx;
				font-size: 36rpx;
				border-bottom: 5rpx solid #f5f5f5;

				.success {
					display: inline-block;
					color: #f00;
					font-size: 24rpx;
					position: relative;
					left: 380rpx;
				}
			}

			.top-two {
				margin-top: 20rpx;
				font-size: 24rpx;
				margin-bottom: 40rpx;

				image {
					margin-left: 20rpx;
					width: 20rpx;
					height: 20rpx;
				}

				p {
					margin-top: 10rpx;
				}
			}
		}

		.top-center {
			padding: 10rpx;

			p {
				margin-top: 15rpx;
				display: flex;
				justify-content: space-between;
			}

			.center-one {
				font-size: 36rpx;
				padding-bottom: 20rpx;
				font-size: 36rpx;
				border-bottom: 5rpx solid #f5f5f5;

			}

			.center-two {
				margin: 20rpx 0;
				padding-bottom: 20rpx;
				border-bottom: 2rpx solid #f5f5f5;
			}

			.center-three {
				margin: 20rpx 0;
				padding-bottom: 20rpx;
				border-bottom: 2rpx solid #f5f5f5;

				.money1 {
					color: #f00;
				}
			}

			.center-four {
				margin: 20rpx 0;
				padding-bottom: 20rpx;
				border-bottom: 5rpx solid #f5f5f5;

				.money1 {
					color: #f00;
				}
			}

			.center-five {
				margin: 20rpx 0;
				padding-bottom: 20rpx;
				border-bottom: 2rpx solid #f5f5f5;

				.money2 {
					font-weight: 550;
					font-size: 36rpx;
				}
			}
		}
	}

	.bottom {
		position: relative;
		top:-230rpx;
		background-color: #fff;
		border-radius: 50rpx;
		margin: 0 20rpx 20rpx;
		padding: 30rpx;
		
		.bottom-top {

			font-size: 36rpx;
			padding-bottom: 20rpx;
			font-size: 36rpx;
			border-bottom: 5rpx solid #f5f5f5;

		}

		.bottom-bottom {
			margin-top: 20rpx;
			p {
				margin-top: 15rpx;
			}
			.star {
				display: inline-block;
			}
		}
	}
</style>